package com.test.particles;

import javax.vecmath.Point2f;

import android.app.AlertDialog;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.view.MotionEvent;

class ClearGLSurfaceView extends GLSurfaceView {
    public ClearGLSurfaceView(Context context) {
        super(context);
        
        mParticles = new ParticleSystem(); 
        mParticles.setTiltCalc(context);
     
        mRenderer = new OpenGLRenderer(mParticles);
        setRenderer(mRenderer);
    }
    
    public void onSizeChanged(int w, int h, int oldw, int oldh)
    {
    	mParticles.setDimensions(new Point2f(1.0f, (float) h / w));
    }

    public boolean onTouchEvent(final MotionEvent event) {
        queueEvent(new Runnable(){
        	final float aspect = (float) getHeight() / getWidth();
        	
            public void run() {
                mParticles.addParticle(event.getX() / getWidth(),
                        aspect * (1.0f - event.getY() / getHeight()));
            }});

            return true;
        }

    public OpenGLRenderer mRenderer;
    public ParticleSystem mParticles;
    
    public AlertDialog ad;
}
